package GUI;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;

import Controller.CompanyManagerController;
import Controller.DBcontroller;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JLabel;
import java.awt.Font;

/**
 * this is the company manager GUI. it has a lot of options: viewing the reports, viewing the orders and workers and approve the changing rate requests.
 * @author all of us.
 */
public class CompanyManagerWin extends JPanel {
	JPanel cur=this;
	JFrame frame;
	JPanel lastPanel;
	public void setLastPanel (JPanel panel)
	{
		this.lastPanel=panel;
	}
	
	public void setFrame (JFrame frame)
	{
		this.frame=frame;
	}
	public JPanel getLastPanel()
	{
		return (JPanel)lastPanel;
	}
	/**
	 * is the constructor. it has buttons for each option: view reports, view orders, view workers and approve requests.
	 */
	public CompanyManagerWin() {

		setBounds(100, 100, 918, 403);
		setBorder(new EmptyBorder(5, 5, 5, 5));
		setLayout(null);
		
		JButton btnViewParkingLots = new JButton("View Parking Lots' Reports");
		btnViewParkingLots.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			}
		});
		btnViewParkingLots.addMouseListener(new MouseAdapter() {
			@Override
			public void mousePressed(MouseEvent arg0) {
				CompanyManagerController.ViewParkingLotReport();
			}
		});
		btnViewParkingLots.setBounds(134, 241, 201, 23);
		add(btnViewParkingLots);
		
		JButton btnPeriodicReport = new JButton("Periodic Report");
		btnPeriodicReport.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			}
		});
		btnPeriodicReport.addMouseListener(new MouseAdapter() {
			@Override
			public void mousePressed(MouseEvent e) {
				ChooseDatePeriodic n=new ChooseDatePeriodic();
				n.setFrame(frame);
				n.setLastPanel(cur);
				n.setVisible(true);
			}
		});
		btnPeriodicReport.setBounds(163, 207, 144, 23);
		add(btnPeriodicReport);
		
		JButton btnPerfomanceReport = new JButton("Perfomance Report");
		btnPerfomanceReport.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			}
		});
		btnPerfomanceReport.addMouseListener(new MouseAdapter() {
			@Override
			public void mousePressed(MouseEvent e) {
				ChooseDatePerformance n=new ChooseDatePerformance();
				n.setFrame(frame);
				n.setLastPanel(cur);
				n.setVisible(true);
			}
		});
		btnPerfomanceReport.setBounds(144, 173, 182, 23);
		add(btnPerfomanceReport);
		
		JButton btnMalfunctionExceptionsReport = new JButton("Malfunction Exceptions Report ");
		btnMalfunctionExceptionsReport.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			}
		});
		btnMalfunctionExceptionsReport.addMouseListener(new MouseAdapter() {
			@Override
			public void mousePressed(MouseEvent e) {
				ChooseDateMalfunc n=new ChooseDateMalfunc();
				n.setFrame(frame);
				n.setLastPanel(cur);
				n.setVisible(true);
			}
		});
		btnMalfunctionExceptionsReport.setBounds(114, 139, 242, 23);
		add(btnMalfunctionExceptionsReport);
		
		JButton btnLogOut = new JButton("Log out");
		btnLogOut.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				frame.setContentPane((JPanel)lastPanel);
			}
		});
		btnLogOut.setBounds(500, 352, 89, 23);
		add(btnLogOut);
		
		JButton btnApproveRequestFor = new JButton("Approve request for changing rates");
		btnApproveRequestFor.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				CompanyManagerController.viewApprove();
			}
		});
		btnApproveRequestFor.setBounds(385, 140, 287, 23);
		add(btnApproveRequestFor);
		
		JButton btnViewWrkers = new JButton("view workers");
		btnViewWrkers.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				CompanyManagerController.viewWorkers();
			}
		});
		btnViewWrkers.setBounds(724, 140, 129, 23);
		add(btnViewWrkers);
		
		JButton btnViewOrders = new JButton("view orders");
		btnViewOrders.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				CompanyManagerController.viewOrders();
			}
		});
		btnViewOrders.setBounds(724, 186, 136, 23);
		add(btnViewOrders);
		
		JLabel lblCompanyManagerWindow = new JLabel("Company Manager Window");
		lblCompanyManagerWindow.setFont(new Font("Tahoma", Font.PLAIN, 14));
		lblCompanyManagerWindow.setBounds(436, 23, 201, 23);
		add(lblCompanyManagerWindow);
		
		JLabel lblApproveSection = new JLabel("Approve Section");
		lblApproveSection.setBounds(468, 115, 107, 14);
		add(lblApproveSection);
		
		JLabel lblViewSection = new JLabel("View Section");
		lblViewSection.setBounds(746, 115, 89, 14);
		add(lblViewSection);
		
		JLabel lblReportsSection = new JLabel("Reports Section");
		lblReportsSection.setBounds(163, 115, 123, 14);
		add(lblReportsSection);
		
		JButton btnStatusPicture = new JButton("Status picture");
		btnStatusPicture.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				CompanyManagerController.viewStatus();
			}
		});
		btnStatusPicture.setBounds(724, 229, 136, 23);
		add(btnStatusPicture);
	}
}
